﻿Imports System.Text.RegularExpressions
Imports System.Text
Imports Seguros.caserDataSet

Public Class frmGestionClientes


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim frmCliente As frmNuevaPoliza
        frmCliente = New frmNuevaPoliza
        frmCliente.MdiParent = Me.MdiParent
        frmCliente.Show()
    End Sub

    Private Sub frmGestionClientes_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated

    End Sub

    Private Sub frmGestionClientes_AutoSizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.AutoSizeChanged

    End Sub

    Private Sub frmGestionClientes_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.GotFocus

    End Sub



    Private Sub frmGestionClientes_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.PersonasTableAdapter.Fill(CaserDataSet.personas)
        CheckBox1_CheckedChanged(chbActivarFiltro, New EventArgs)
        Dim sError As String = ""

        sError = CargarVistaPolizaFlitro(CaserDataSet.VistaPolizaFiltro)
        If sError <> "" Then
            MessageBox.Show(sError, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If

        If Me.Tag IsNot Nothing Then
            Dim cadena As String = Me.Tag
            Dim idcontacto As Integer = cadena.Split(";")(0)
            Dim idpersona As Integer = cadena.Split(";")(1)
            For Each row As DataGridViewRow In dgPersonas.Rows
                If (row.Cells(0).Value = idpersona) Then

                    dgPersonas.CurrentCell = row.Cells(1)
                    row.Selected = True
                    dgPersonas_SelectionChanged(dgPersonas, New System.EventArgs)

                End If
            Next
            For Each row As DataGridViewRow In dgContactos.Rows
                If (row.Cells(0).Value = idcontacto) Then
                    dgContactos.CurrentCell = row.Cells(1)
                    row.Selected = True


                End If
            Next

        End If

    End Sub

    Private Sub txtBuscarNombre_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtBuscarNombre.TextChanged
        PersonasBindingSource.Filter = "nombre Like '" & txtBuscarNombre.Text & "%' or apellido Like '" & txtBuscarNombre.Text & "%'"
    End Sub
    Private Sub txtBuscarDni_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtBuscarDni.TextChanged
        PersonasBindingSource.Filter = "dni Like '" & txtBuscarDni.Text & "%'"
    End Sub
    Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
        Dim frmCliente As NuevoCliente
        frmCliente = New NuevoCliente
        frmCliente.MdiParent = Me.MdiParent
        frmCliente.Show()
    End Sub


    Public Sub dgPersonas_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgPersonas.SelectionChanged
        If dgPersonas.CurrentRow IsNot Nothing Then


            Dim rowPersona = CType(dgPersonas.CurrentRow.DataBoundItem.row, caserDataSet.personasRow)
            txtNombre.Text = rowPersona.nombre
            txtApellidos.Text = rowPersona.apellido
            txtDireccion.Text = rowPersona.direccion
            txtDni.Text = rowPersona.dni
            txtEmail.Text = rowPersona.email
            txtLocalidad.Text = rowPersona.localidad
            txtTipoVivienda.Text = rowPersona.tipoVivienda
            txtTlfn1.Text = rowPersona.telefono1
            txtTlfn2.Text = rowPersona.telefono2
            dtpFechaCarnet.Value = rowPersona.fechaCarnet
            dtpFechaNac.Value = rowPersona.fechaNac
            nudNumHijos.Value = rowPersona.numHijos
            nudRenta.Value = rowPersona.nivelRenta
            cmbTrabajo.SelectedItem = rowPersona.trabajo
            Dim sError As String = ""
            sError = CargarVistaRelaciones(CaserDataSet.VistaRelaciones, rowPersona.Id)

            If sError <> "" Then
                MessageBox.Show(sError, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
            End If


            sError = CargarVistaPolizaPorCliente(CaserDataSet.VistaPolizasPorCliente, rowPersona.Id)

            If sError <> "" Then
                MessageBox.Show(sError, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
            End If


            sError = CargarCuentasById(CaserDataSet.cuentacorriente, rowPersona.Id)

            If sError <> "" Then
                MessageBox.Show(sError, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
            End If

            sError = CargarContactosById(CaserDataSet.contacto, rowPersona.Id)

            If sError <> "" Then
                MessageBox.Show(sError, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
            End If

            ContactoBindingSource.Filter = " idLogin = " & Principal.rowlogin.id
        End If
    End Sub



    Private Sub btnModificar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnModificar.Click
        If (validar()) Then
            If dgPersonas.CurrentRow IsNot Nothing Then
                Dim dsCaser = New caserDataSet
                Dim cliente As caserDataSet.personasRow

                Dim sError4 = CargarClienteById(dsCaser.personas, CType(dgPersonas.CurrentRow.DataBoundItem.row, caserDataSet.personasRow).Id)

                If sError4 <> "" Then
                    MessageBox.Show(sError4, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)

                Else
                    cliente = dsCaser.personas.Rows(0)
                    cliente.nombre = txtNombre.Text
                    cliente.apellido = txtApellidos.Text
                    cliente.direccion = txtDireccion.Text
                    cliente.dni = txtDni.Text
                    cliente.email = txtEmail.Text
                    cliente.localidad = txtLocalidad.Text
                    cliente.tipoVivienda = txtTipoVivienda.Text
                    cliente.telefono1 = txtTlfn1.Text
                    cliente.telefono2 = txtTlfn2.Text
                    cliente.fechaCarnet = dtpFechaCarnet.Value
                    cliente.fechaNac = dtpFechaNac.Value
                    cliente.numHijos = nudNumHijos.Value
                    cliente.nivelRenta = nudRenta.Value
                    cliente.trabajo = cmbTrabajo.SelectedItem

                    Dim sError As String = ""

                    sError = GuardarTabla(dsCaser.personas)

                    If sError <> "" Then
                        MessageBox.Show(sError, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)

                    End If

                    Dim sError3 As String = ""
                    sError3 = CargarTabla(dsCaser.relaciones)


                    If sError3 <> "" Then
                        MessageBox.Show(sError, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)

                    End If

                    Dim sError1 As String = ""

                    Dim idPersona1 As Integer
                    idPersona1 = cliente.Id

                    For Each relaRow As relacionesRow In dsCaser.relaciones.Select("idPersona1 = " & cliente.Id & "OR idPersona2 = " & cliente.Id)
                        relaRow.Delete()
                    Next

                    For Each row As DataGridViewRow In dgFamiliares.Rows
                        dsCaser.relaciones.AddrelacionesRow(idPersona1, row.Cells(0).Value, row.Cells(4).Value)

                    Next

                    sError = GuardarTabla(dsCaser.relaciones)

                    If sError1 <> "" Then
                        MessageBox.Show(sError, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)

                    End If

                    sError = GuardarTabla(CaserDataSet.cuentacorriente)

                    If sError1 <> "" Then
                        MessageBox.Show(sError, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)

                    End If


                    If sError = "" And sError1 = "" Then
                        CType(Me.MdiParent, Principal).Estado = "Cliente modificado.. "
                        Me.PersonasTableAdapter.Fill(CaserDataSet.personas)
                        For Each row As DataGridViewRow In dgPersonas.Rows
                            If (row.Cells(0).Value = cliente.Id) Then

                                dgPersonas.CurrentCell = row.Cells(1)
                                row.Selected = True
                                dgPersonas_SelectionChanged(dgPersonas, New System.EventArgs)

                            End If
                        Next
                    End If
                End If
            End If
        End If

    End Sub
    Private Function validar() As Boolean
        Dim valido = True
        Dim sError = ""
        If txtNombre.Text = "" Then
            valido = False
            sError = "El campo nombre no puede ser vacio" & vbCrLf
        End If
        If txtEmail.Text <> String.Empty Then
            Dim re As Regex = New Regex("^[\w._%-]+@[\w.-]+\.[a-zA-Z]{2,4}$")
            Dim m As Match = re.Match(txtEmail.Text)
            If m.Captures.Count = 0 Then
                valido = False
                sError = "No es un email valido" & vbCrLf
            End If
        End If
        If (txtDni.Text <> "" AndAlso Not (Verificar_CIF(txtDni.Text) Or Verificar_NIF(txtDni.Text))) Then
            valido = False
            sError += " El cif o el dni no es valido" & vbCrLf
        End If


        If sError <> "" Then
            MessageBox.Show(sError, "Datos Incorrectos", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If
        ' Compruebo si el formato de la dirección es correcto.
        Return valido
    End Function
    Public Function Verificar_CIF(ByVal valor As String) As Boolean
        Dim strLetra As String, strNumero As String, strDigit As String
        Dim strDigitAux As String
        Dim auxNum As Integer
        Dim i As Integer
        Dim suma As Integer
        Dim letras As String

        letras = "ABCDEFGHKLMPQSX"

        valor = UCase(valor)

        If Len(valor) < 9 OrElse Not IsNumeric(Mid(valor, 2, 7)) Then
            Return False
        End If

        strLetra = Mid(valor, 1, 1)     ' letra del CIF
        strNumero = Mid(valor, 2, 7)    ' Codigo de Control
        strDigit = Mid(valor, 9)        ' CIF menos primera y ultima posiciones

        If InStr(letras, strLetra) = 0 Then ' comprobamos la letra del CIF (1ª posicion)
            Return False
        End If

        For i = 1 To 7
            If i Mod 2 = 0 Then
                suma = suma + CInt(Mid(strNumero, i, 1))
            Else
                auxNum = CInt(Mid(strNumero, i, 1)) * 2
                suma = suma + (auxNum \ 10) + (auxNum Mod 10)
            End If
        Next

        suma = (10 - (suma Mod 10)) Mod 10

        Select Case strLetra
            Case "K", "P", "Q", "S"
                suma = suma + 64
                strDigitAux = Chr(suma)
            Case "X"
                strDigitAux = Mid(CalculaNIF(strNumero), 8, 1)
            Case Else
                strDigitAux = CStr(suma)
        End Select

        If strDigit = strDigitAux Then
            Return True
        Else
            Return False
        End If
    End Function
    Public Function Verificar_NIF(ByVal valor As String) As Boolean
        Dim aux As String

        valor = valor.ToUpper ' ponemos la letra en mayúscula
        aux = valor.Substring(0, valor.Length - 1) ' quitamos la letra del NIF

        If aux.Length >= 7 AndAlso IsNumeric(aux) Then
            aux = CalculaNIF(aux) ' calculamos la letra del NIF para comparar con la que tenemos
        Else
            Return False
        End If

        If valor <> aux Then ' comparamos las letras
            Return False
        End If

        Return True
    End Function

    Private Function CalculaNIF(ByVal strA As String) As String
        '----------------------------------------------------------------------
        ' Calcular la letra del NIF
        ' Código original adaptado a Visual Basic                   (13/Sep/95)
        ' Adaptado a Visual Basic .NET (VB 9.0/2008)                (09/May/08)
        ' y convertido en función que devuelve el NIF correcto
        '----------------------------------------------------------------------
        Const cCADENA As String = "TRWAGMYFPDXBNJZSQVHLCKE"
        Const cNUMEROS As String = "0123456789"
        Dim a, b, c, NIF As Integer
        Dim sb As New StringBuilder

        strA = Trim(strA)
        If Len(strA) = 0 Then Return ""

        ' Dejar sólo los números
        For i As Integer = 0 To strA.Length - 1
            If cNUMEROS.IndexOf(strA(i)) > -1 Then
                sb.Append(strA(i))
            End If
        Next

        strA = sb.ToString
        a = 0
        NIF = CInt(Val(strA))
        Do
            b = CInt(Int(NIF / 24))
            c = NIF - (24 * b)
            a = a + c
            NIF = b
        Loop While b <> 0
        b = CInt(Int(a / 23))
        c = a - (23 * b)

        Return strA & Mid(cCADENA, CInt(c + 1), 1)
    End Function

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddFam.Click
        Dim formPersonas As frmPersonas
        Dim duplicado As Boolean = False
        formPersonas = New frmPersonas
        formPersonas.parentesco(True)
        formPersonas.ShowDialog()
        If (formPersonas.Tag <> Nothing) Then
            Dim cadena As String
            cadena = formPersonas.Tag.ToString()
            For Each fila As DataGridViewRow In dgFamiliares.Rows
                If (fila.Cells(0).Value = (cadena.Split(";")(0))) Then
                    MessageBox.Show("Familiar ya introducido por favor seleccione otro.")
                    duplicado = True
                    Exit For
                End If
            Next
            If (Not duplicado) Then
                CaserDataSet.VistaRelaciones.AddVistaRelacionesRow(cadena.Split(";")(1), cadena.Split(";")(2), cadena.Split(";")(3), cadena.Split(";")(4), cadena.Split(";")(0))
            End If

        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If dgFamiliares.CurrentRow IsNot Nothing Then
            If MessageBox.Show("¿Estas seguro que desea borrar el familiar seleccionado?.", "Eliminar", MessageBoxButtons.OKCancel) = Windows.Forms.DialogResult.OK Then
                dgFamiliares.Rows.Remove(dgFamiliares.CurrentRow)

            End If
        End If
    End Sub

    Private Sub btnEliminarCuenta_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEliminarCuenta.Click
        If lstCuentasCorientes.SelectedItem IsNot Nothing Then
            CaserDataSet.cuentacorriente.Select("id = " & lstCuentasCorientes.SelectedValue)(0).Delete()
        End If
    End Sub

    Private Sub btnAñadirCuenta_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAñadirCuenta.Click
        If dgPersonas.CurrentRow IsNot Nothing Then
            If validarCuenta() Then
                CaserDataSet.cuentacorriente.AddcuentacorrienteRow(CType(dgPersonas.CurrentRow.DataBoundItem.row, caserDataSet.personasRow).Id, txtCuenta.Text)
            End If
        End If
    End Sub

    Private Function validarCuenta() As Boolean
        Dim valido = True
        Dim sError = ""
        If txtCuenta.Text = "" Then
            valido = False
            sError = "El introduzca número de cuenta" & vbCrLf
        End If

        If sError <> "" Then
            MessageBox.Show(sError, "Datos Incorrectos", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If
        Return valido
    End Function

    Private Sub Button3_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        If dgPersonas.CurrentRow IsNot Nothing Then
            Dim frm As frmNuevoContacto
            frm = New frmNuevoContacto()
            frm.Tag = CType(dgPersonas.CurrentRow.DataBoundItem.row, caserDataSet.personasRow).Id
            frm.ShowDialog()

            dgPersonas_SelectionChanged(dgPersonas, New System.EventArgs())
        End If
    End Sub


 
    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        If dgPersonas.CurrentRow IsNot Nothing Then
            Dim frm As frmNuevaPoliza
            frm = New frmNuevaPoliza()
            If dgPersonas.SelectedRows IsNot Nothing Then
                frm.Tag = "N;" & CType(dgPersonas.CurrentRow.DataBoundItem.row, caserDataSet.personasRow).Id & ";" & CType(dgPersonas.CurrentRow.DataBoundItem.row, caserDataSet.personasRow).nombre & ";" & CType(dgPersonas.CurrentRow.DataBoundItem.row, caserDataSet.personasRow).apellido & ";" & CType(dgPersonas.CurrentRow.DataBoundItem.row, caserDataSet.personasRow).dni
            Else
                frm.Tag = Nothing
            End If
            frm.ShowDialog()
            dgPersonas_SelectionChanged(dgPersonas, New System.EventArgs())
        End If
    End Sub

    Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If dgContactos.CurrentRow IsNot Nothing Then
            If MessageBox.Show("¿Estas seguro que desea borrar el contacto seleccionado?.", "Eliminar", MessageBoxButtons.OKCancel) = Windows.Forms.DialogResult.OK Then
                Dim sError As String = ""

                sError = CargarTabla(CaserDataSet.notificaciones)

                CaserDataSet.notificaciones.Select("idNotificacion = " & dgContactos.CurrentRow.Cells(0).Value)(0).Delete()
                sError = GuardarTabla(CaserDataSet.notificaciones)

                dgContactos.Rows.Remove(dgContactos.CurrentRow)

                sError = GuardarTabla(CaserDataSet.contacto)


                If sError <> "" Then
                    MessageBox.Show(sError, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
                Else
                    Principal.contarNotificaciones()
                End If

            End If
        End If
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        If dgPolizas.CurrentRow IsNot Nothing Then
            If MessageBox.Show("¿Estas seguro que desea borrar la póliza seleccionada?.", "Eliminar", MessageBoxButtons.OKCancel) = Windows.Forms.DialogResult.OK Then
                Dim sError As String = ""

                Select Case dgPolizas.CurrentRow.Cells(3).Value

                    Case "AUTO"

                        sError = CargarTabla(CaserDataSet._auto)
                        CaserDataSet._auto.Select("id = " & dgPolizas.CurrentRow.Cells(0).Value)(0).Delete()
                        sError = GuardarTabla(CaserDataSet._auto)

                    Case "HOGAR"

                        sError = CargarTabla(CaserDataSet.hogar)
                        CaserDataSet.hogar.Select("id = " & dgPolizas.CurrentRow.Cells(0).Value)(0).Delete()
                        sError = GuardarTabla(CaserDataSet.hogar)

                    Case "PYMECOMERCIO"

                        sError = CargarTabla(CaserDataSet.pymecomercio)
                        CaserDataSet.pymecomercio.Select("id = " & dgPolizas.CurrentRow.Cells(0).Value)(0).Delete()
                        sError = GuardarTabla(CaserDataSet.pymecomercio)



                    Case Else
                        sError = CargarTabla(CaserDataSet.poliza)
                        CaserDataSet.poliza.Select("id = " & dgPolizas.CurrentRow.Cells(0).Value)(0).Delete()
                        sError = GuardarTabla(CaserDataSet.poliza)
                End Select



                If sError <> "" Then
                    MessageBox.Show(sError, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)

                End If

                sError = CargarVistaPolizaPorCliente(CaserDataSet.VistaPolizasPorCliente, CType(dgPersonas.CurrentRow.DataBoundItem.row, caserDataSet.personasRow).Id)

                If sError <> "" Then
                    MessageBox.Show(sError, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
                End If



            End If
        End If
    End Sub

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        If dgPersonas.CurrentRow IsNot Nothing Then
            Dim frm As frmNuevaPoliza
            frm = New frmNuevaPoliza()
            Dim tipo As String
               Select dgPolizas.CurrentRow.Cells(3).Value

                Case "AUTO"
                    tipo = "A"
                Case "HOGAR"
                    tipo = "H"
                Case "PYMECOMERCIO"
                    tipo = "C"
                Case Else
                    tipo = "P"
            End Select



            If dgPersonas.SelectedRows IsNot Nothing Then
                frm.Tag = "M;" & CType(dgPersonas.CurrentRow.DataBoundItem.row, caserDataSet.personasRow).Id & ";" & CType(dgPersonas.CurrentRow.DataBoundItem.row, caserDataSet.personasRow).nombre & ";" & CType(dgPersonas.CurrentRow.DataBoundItem.row, caserDataSet.personasRow).apellido & ";" & CType(dgPersonas.CurrentRow.DataBoundItem.row, caserDataSet.personasRow).dni & ";" & CType(dgPolizas.CurrentRow.DataBoundItem.row, caserDataSet.VistaPolizasPorClienteRow).Id & ";" & tipo
            Else
                frm.Tag = Nothing
            End If
            frm.ShowDialog()
            dgPersonas_SelectionChanged(dgPersonas, New System.EventArgs())
        End If
    End Sub

    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chbActivarFiltro.CheckedChanged, rbtClienteOro.CheckedChanged, rbtClientePlata.CheckedChanged, rbtClienteBronce.CheckedChanged, rbtsinPoliza.CheckedChanged
        RemoveHandler dgPersonas.SelectionChanged, AddressOf dgPersonas_SelectionChanged
        PersonasBindingSource.Filter = ""
        If chbActivarFiltro.Checked Then
            gbrFiltro.Enabled = True

           
            Dim ids = ""

            For Each row As caserDataSet.personasRow In CaserDataSet.personas

                Dim count = CaserDataSet.VistaPolizaFiltro.Select("idPersona = " & row.Id & "and competencia = 'false'").Count
                If (rbtClienteOro.Checked AndAlso count > 3) Then
                    ids += row.Id & ","
                ElseIf rbtClientePlata.Checked AndAlso (count = 2 Or count = 3) Then
                    ids += row.Id & ","
                ElseIf rbtClienteBronce.Checked AndAlso count = 1 Then
                    ids += row.Id & ","
                ElseIf rbtsinPoliza.Checked AndAlso count = 0 Then
                    ids += row.Id & ","
                End If

            Next

            If ids <> "" Then
                ids = ids.Remove(ids.Length - 1, 1)
                PersonasBindingSource.Filter = "id in (" & ids & ")"
            Else
                PersonasBindingSource.Filter = "id = 0"
            End If


        Else
            gbrFiltro.Enabled = False

        End If
        AddHandler dgPersonas.SelectionChanged, AddressOf dgPersonas_SelectionChanged
    End Sub

    Private Sub btnDel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDel.Click
        If (dgPersonas.CurrentRow IsNot Nothing) Then
            CType(dgPersonas.CurrentRow.DataBoundItem.row, caserDataSet.personasRow).Delete()
            Dim sError = GuardarTabla(CaserDataSet.personas)

            If sError <> "" Then
                MessageBox.Show(sError, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)

            End If

        End If
    End Sub

    Public Sub New()

        ' Llamada necesaria para el diseñador.
        InitializeComponent()

        ' Agregue cualquier inicialización después de la llamada a InitializeComponent().

    End Sub

    
    Private Sub btnImprimir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnImprimir.Click
        If chbActivarFiltro.Checked Then

            If rbtClienteBronce.Checked Then
                PrintDGV.Print_DataGridView(dgPersonas, "Listado de clientes BRONCE", Nothing)
            ElseIf rbtClienteOro.Checked Then
                PrintDGV.Print_DataGridView(dgPersonas, "Listado de clientes ORO", Nothing)

            ElseIf rbtClientePlata.Checked Then
                PrintDGV.Print_DataGridView(dgPersonas, "Listado de clientes PLATA", Nothing)

            ElseIf rbtsinPoliza.Checked Then
                PrintDGV.Print_DataGridView(dgPersonas, "Listado de clientes SIN PÓLIZA", Nothing)
            End If

        Else
            PrintDGV.Print_DataGridView(dgPersonas, "Listado de todos los clientes", Nothing)
        End If
    End Sub

    



End Class